def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0:
            return False
    return True

def nearest_prime_number(s):
    numbers = {'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}

    try:
        number = int(''.join([str(numbers[word]) for word in s.split()]))
        if 100 <= number <= 999:
            for i in range(number, 1000):
                if is_prime(i):
                    print(i)
                    break
                if is_prime(number - i):
                    print(number - i)
                    break
        else:
            print("wrong input")
    except:
        print("wrong input")

s = input("Введите три слова: ")
nearest_prime_number(s)
